package cn.mothin.frame.help;

import cn.mothin.frame.core.exception.SystemException;
import cn.mothin.frame.help.config.ConfigReader;
import cn.mothin.frame.util.encrypt.MD5;

public class Password {
    public static final int MD5TIME=ConfigReader.getInstance().getMD5Time();
    
	/**
	 * 密码加密
	 * @return
	 * @throws Exception 
	 */
	public static String encrypt(String password){
		try{
			return MD5.makeMD5(password, MD5TIME);
		}catch(Exception e){
			throw new SystemException();
		}
	}
	
	public static boolean equals(String passwordInut,String passwordRecord,String random){
		if(random==null||passwordRecord==null||passwordInut==null){
			return false;
		}
		String s = MD5.makeMD5(passwordRecord + random);
		if (s.equals(passwordInut)) {
			return true;
		}
		return false;
	}
}
